var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function o() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((o.prototype = i.prototype), new o()));
      };
    })(),
  SendGoodsDetailDialog = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.max = 99),
        (t.min = 1),
        (t.step = 1),
        (t.num = 1),
        (t.onLoadEmailItemTypeOne = {
          caller: t,
          code: 1181,
          method: function (e) {},
        }),
        (t.onLoadEmailItemTypeZhuangBei = {
          caller: t,
          code: 1182,
          method: function (e) {
            WebSocketService.send({ c: 1025, d: null });
          },
        }),
        (t.onLoadEmailItemTypeBaoShi = {
          caller: t,
          code: 1183,
          method: function (e) {
            WebSocketService.send({ c: 1025, d: null });
          },
        }),
        (t.onLoadEmailItemTypeFuJiang = {
          caller: t,
          code: 1184,
          method: function (e) {
            0 != e.code && ToastView.toastView(e.msg),
              ToastView.toastView(e.data);
          },
        }),
        t.btn_goods_dele.on(Laya.Event.CLICK, t, t.onDidClickItemFn),
        t.btn_goods_plus.on(Laya.Event.CLICK, t, t.onDidClickItemFn),
        t.slider_emailGoods.on(Laya.Event.CHANGE, t, t.onSliderGoodsChange),
        t.btn_email_cancle.on(Laya.Event.CLICK, t, t.onDidClickCloseFn),
        t.btn_email_addItem.on(Laya.Event.CLICK, t, t.onEmailAddItemFn),
        WebSocketService.addListener(t.onLoadEmailItemTypeOne, !0),
        WebSocketService.addListener(t.onLoadEmailItemTypeZhuangBei, !0),
        WebSocketService.addListener(t.onLoadEmailItemTypeBaoShi, !0),
        WebSocketService.addListener(t.onLoadEmailItemTypeFuJiang, !0),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showGoodsView = function (e, i) {
        null == this.detailVC &&
          ((this.detailVC = new t()), (this.detailVC.zOrder = 1e3)),
          this.detailVC.popup(!0),
          (this.detailVC.goodsObj = e),
          void 0 != e.num
            ? (this.detailVC.maxStr = e.num)
            : (this.detailVC.maxStr = "1"),
          (this.detailVC.text_email_money.text = ""),
          (this.detailVC.type = i),
          (this.detailVC.num = 1),
          (this.detailVC.min = 1),
          (this.detailVC.label_emailGoods_title.text = e.name),
          (this.detailVC.max = parseInt(this.detailVC.maxStr)),
          (this.detailVC.slider_emailGoods.max = this.detailVC.max),
          (this.detailVC.slider_emailGoods.value = 1),
          (this.detailVC.label_goods_number.text = "1/" + this.detailVC.maxStr),
          "5" == i
            ? ((this.detailVC.btn_goods_dele.visible = !1),
              (this.detailVC.btn_goods_plus.visible = !1),
              (this.detailVC.slider_emailGoods.visible = !1))
            : ((this.detailVC.btn_goods_dele.visible = !0),
              (this.detailVC.btn_goods_plus.visible = !0),
              (this.detailVC.slider_emailGoods.visible = !0));
      }),
      (t.prototype.onEmailAddItemFn = function () {
        var e = this.slider_emailGoods.value,
          t = Number(this.text_email_money.text);
        "1" == this.type || "3" == this.type || "4" == this.type
          ? WebSocketService.send({
              c: 1181,
              d: { id: this.goodsObj.id, c: e, m: t },
            })
          : "2" == this.type
          ? WebSocketService.send({
              c: 1182,
              d: { id: this.goodsObj.id, m: t },
            })
          : "31" == this.type
          ? WebSocketService.send({
              c: 1183,
              d: { id: this.goodsObj.id, m: t, t: 1 },
            })
          : "32" == this.type
          ? WebSocketService.send({
              c: 1183,
              d: { id: this.goodsObj.id, m: t, t: 2 },
            })
          : "5" == this.type &&
            WebSocketService.send({
              c: 1184,
              d: { id: this.goodsObj.id, m: t },
            }),
          this.close();
      }),
      (t.prototype.onDidClickItemFn = function (e) {
        "item0" == e.target.name
          ? ((this.num = this.num - this.step),
            this.num < this.min && (this.num = this.min),
            (this.slider_emailGoods.value = this.num))
          : "item1" == e.target.name &&
            ((this.num = this.num + this.step),
            this.num > this.max && (this.num = this.max),
            (this.slider_emailGoods.value = this.num)),
          (this.label_goods_number.text =
            this.slider_emailGoods.value + "/" + this.maxStr);
      }),
      (t.prototype.onSliderGoodsChange = function () {
        (this.num = this.slider_emailGoods.value),
          (this.label_goods_number.text =
            this.slider_emailGoods.value + "/" + this.maxStr);
      }),
      (t.prototype.onDidClickCloseFn = function () {
        this.close(), SendEmailGoodsDialog.showEmailGoodsView();
      }),
      (t.close = function () {
        this.detailVC && this.detailVC.close();
      }),
      t
    );
  })(ui.EmailController.SendGoodsDetailDialogUI);
